package com.commons.dbutils.connection;

public class Configuration  {
	private int initialPoolSize=3;//初始化获取连接数
	
	private int acquireIncrement = 3;//当连接池中的连接耗尽的时候一次同时获取的连接数
	
	private int maxIdleTime = 600;//最大空闲时间,未使用则连接被丢弃
	
	private int acquireRetryAttempts=5;//从数据库获取新连接失败后重复尝试的次数
	
	private int acquireRetryDelay =1000;//两次连接中间隔时间，单位毫秒
	private boolean autoCommitOnClose  =false;//连接关闭时默认将所有未提交的操作回滚
	
	private String automaticTestTable = null;//自动检测连接临时表
	/**
	 * 获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常。但是数据源仍有效 
	 * 保留，并在下次调用getConnection()的时候继续尝试获取连接。如果设为true，那么在尝试 
	 * 获取连接失败后该数据源将申明已断开并永久关闭。Default: false
	 */
	private boolean breakAfterAcquireFailure=false;
	
	/**
	 * 当连接池用完时客户端调用getConnection()后等待获取新连接的时间，超时后将抛出 
     * SQLException,如设为0则无限期等待。单位毫秒。Default: 0
	 */
	private int checkoutTimeout=0;
	//每60秒检查所有连接池中的空闲连接
	private int idleConnectionTestPeriod=600;
	
	//JDBC的标准参数，用以控制数据源内加载的PreparedStatements数量。但由于预缓存的statements 
	//属于单个connection而不是整个连接池。所以设置这个参数需要考虑到多方面的因素。 
	//如果maxStatements与maxStatementsPerConnection均为0，则缓存被关闭。Default: 0
	private int maxStatements=100;

	//maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0
	private int maxStatementsPerConnection=0;

	//c3p0是异步操作的，缓慢的JDBC操作通过帮助进程完成。扩展这些操作可以有效的提升性能 
	//通过多线程实现多个操作同时被执行。Default: 3
	private int numHelperThreads=3;

	//通过实现ConnectionTester或QueryConnectionTester的类来测试连接。类名需制定全路径。 
	//Default: com.mchange.v2.c3p0.impl.DefaultConnectionTester
	private String connectionTesterClassName=null;

	//指定c3p0 libraries的路径，如果（通常都是这样）在本地即可获得那么无需设置，默认null即可 
	//Default: null
	private String factoryClassLocation= null;

	//当用户调用getConnection()时使root用户成为去获取连接的用户。主要用于连接池连接非c3p0 
	//的数据源时。Default: nul
	private String overrideDefaultUser="root";

	//与overrideDefaultUser参数对应使用的一个参数。Default: null
	private String overrideDefaultPassword=null;

	//定义所有连接测试都执行的测试语句。在使用连接测试的情况下这个一显著提高测试速度。注意： 
	//测试的表必须在初始数据源的时候就存在。Default: null
	private String preferredTestQuery=null;

	//因性能消耗大请只在需要的时候使用它。如果设为true那么在每个connection提交的 
	//时候都将校验其有效性。建议使用idleConnectionTestPeriod或automaticTestTable 
	//等方法来提升连接测试的性能。Default: false 
	private boolean testConnectionOnCheckout=false;

	//如果设为true那么在取得连接的同时将校验连接的有效性。Default: false 
	private boolean testConnectionOnCheckin=false;
	
	
	
	private String connetionURL=null;
	private String driversClass=null;
	private String userName=null;
	private String passWord=null;
	private int queryTimeOut=2;
	private int insertUpdateTimeOut=5;
	private int batchTimeOut=30;
	private int minPoolSize=5;
	private int maxPoolSize=50;
	public int getInitialPoolSize() {
		return initialPoolSize;
	}
	public void setInitialPoolSize(int initialPoolSize) {
		this.initialPoolSize = initialPoolSize;
	}
	public int getAcquireIncrement() {
		return acquireIncrement;
	}
	public void setAcquireIncrement(int acquireIncrement) {
		this.acquireIncrement = acquireIncrement;
	}
	public int getMaxIdleTime() {
		return maxIdleTime;
	}
	public void setMaxIdleTime(int maxIdleTime) {
		this.maxIdleTime = maxIdleTime;
	}
	public int getAcquireRetryAttempts() {
		return acquireRetryAttempts;
	}
	public void setAcquireRetryAttempts(int acquireRetryAttempts) {
		this.acquireRetryAttempts = acquireRetryAttempts;
	}
	public int getAcquireRetryDelay() {
		return acquireRetryDelay;
	}
	public void setAcquireRetryDelay(int acquireRetryDelay) {
		this.acquireRetryDelay = acquireRetryDelay;
	}
	public boolean isAutoCommitOnClose() {
		return autoCommitOnClose;
	}
	public void setAutoCommitOnClose(boolean autoCommitOnClose) {
		this.autoCommitOnClose = autoCommitOnClose;
	}
	public String getAutomaticTestTable() {
		return automaticTestTable;
	}
	public void setAutomaticTestTable(String automaticTestTable) {
		this.automaticTestTable = automaticTestTable;
	}
	public boolean isBreakAfterAcquireFailure() {
		return breakAfterAcquireFailure;
	}
	public void setBreakAfterAcquireFailure(boolean breakAfterAcquireFailure) {
		this.breakAfterAcquireFailure = breakAfterAcquireFailure;
	}
	public int getCheckoutTimeout() {
		return checkoutTimeout;
	}
	public void setCheckoutTimeout(int checkoutTimeout) {
		this.checkoutTimeout = checkoutTimeout;
	}
	public int getIdleConnectionTestPeriod() {
		return idleConnectionTestPeriod;
	}
	public void setIdleConnectionTestPeriod(int idleConnectionTestPeriod) {
		this.idleConnectionTestPeriod = idleConnectionTestPeriod;
	}
	public int getMaxStatements() {
		return maxStatements;
	}
	public void setMaxStatements(int maxStatements) {
		this.maxStatements = maxStatements;
	}
	public int getMaxStatementsPerConnection() {
		return maxStatementsPerConnection;
	}
	public void setMaxStatementsPerConnection(int maxStatementsPerConnection) {
		this.maxStatementsPerConnection = maxStatementsPerConnection;
	}
	public int getNumHelperThreads() {
		return numHelperThreads;
	}
	public void setNumHelperThreads(int numHelperThreads) {
		this.numHelperThreads = numHelperThreads;
	}
	public String getConnectionTesterClassName() {
		return connectionTesterClassName;
	}
	public void setConnectionTesterClassName(String connectionTesterClassName) {
		this.connectionTesterClassName = connectionTesterClassName;
	}
	public String getFactoryClassLocation() {
		return factoryClassLocation;
	}
	public void setFactoryClassLocation(String factoryClassLocation) {
		this.factoryClassLocation = factoryClassLocation;
	}
	public String getOverrideDefaultUser() {
		return overrideDefaultUser;
	}
	public void setOverrideDefaultUser(String overrideDefaultUser) {
		this.overrideDefaultUser = overrideDefaultUser;
	}
	public String getOverrideDefaultPassword() {
		return overrideDefaultPassword;
	}
	public void setOverrideDefaultPassword(String overrideDefaultPassword) {
		this.overrideDefaultPassword = overrideDefaultPassword;
	}
	public String getPreferredTestQuery() {
		return preferredTestQuery;
	}
	public void setPreferredTestQuery(String preferredTestQuery) {
		this.preferredTestQuery = preferredTestQuery;
	}
	public boolean isTestConnectionOnCheckout() {
		return testConnectionOnCheckout;
	}
	public void setTestConnectionOnCheckout(boolean testConnectionOnCheckout) {
		this.testConnectionOnCheckout = testConnectionOnCheckout;
	}
	public boolean isTestConnectionOnCheckin() {
		return testConnectionOnCheckin;
	}
	public void setTestConnectionOnCheckin(boolean testConnectionOnCheckin) {
		this.testConnectionOnCheckin = testConnectionOnCheckin;
	}
	public String getConnetionURL() {
		return connetionURL;
	}
	public void setConnetionURL(String connetionURL) {
		this.connetionURL = connetionURL;
	}
	public String getDriversClass() {
		return driversClass;
	}
	public void setDriversClass(String driversClass) {
		this.driversClass = driversClass;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassWord() {
		return passWord;
	}
	public void setPassWord(String passWord) {
		this.passWord = passWord;
	}
	public int getQueryTimeOut() {
		return queryTimeOut;
	}
	public void setQueryTimeOut(int queryTimeOut) {
		this.queryTimeOut = queryTimeOut;
	}
	public int getInsertUpdateTimeOut() {
		return insertUpdateTimeOut;
	}
	public void setInsertUpdateTimeOut(int insertUpdateTimeOut) {
		this.insertUpdateTimeOut = insertUpdateTimeOut;
	}
	public int getBatchTimeOut() {
		return batchTimeOut;
	}
	public void setBatchTimeOut(int batchTimeOut) {
		this.batchTimeOut = batchTimeOut;
	}
	public int getMinPoolSize() {
		return minPoolSize;
	}
	public void setMinPoolSize(int minPoolSize) {
		this.minPoolSize = minPoolSize;
	}
	public int getMaxPoolSize() {
		return maxPoolSize;
	}
	public void setMaxPoolSize(int maxPoolSize) {
		this.maxPoolSize = maxPoolSize;
	}
	
	
	
}